extern "C"
{
__declspec(dllimport) NTSTATUS __stdcall NtQueryInformationThread (
    IN HANDLE ThreadHandle,
    IN THREADINFOCLASS ThreadInformationClass,
    OUT PVOID ThreadInformation,
    IN ULONG ThreadInformationLength,
    OUT PULONG ReturnLength OPTIONAL);

__declspec(dllimport) NTSTATUS __stdcall RtlQueryProcessDebugInformation(__in ULONG ProcessId,__in ULONG DebugInfoClassMask,__inout PDEBUG_BUFFER  DebugBuffer); 
__declspec(dllimport) PDEBUG_BUFFER __stdcall RtlCreateQueryDebugBuffer(__in ULONG  Size,__in BOOLEAN  EventPair);
__declspec(dllimport) NTSTATUS __stdcall RtlDestroyQueryDebugBuffer(__in PDEBUG_BUFFER  DebugBuffer);
__declspec(dllimport) VOID     __stdcall RtlDestroyHandleTable(__inout PRTL_HANDLE_TABLE HandleTable);
__declspec(dllimport) NTSTATUS __stdcall LdrUnloadDll(__in HANDLE ModuleHandle);
__declspec(dllimport) NTSTATUS __stdcall NtCreateEventPair(__out PHANDLE EventPairHandle,__in ACCESS_MASK DesiredAccess,__in POBJECT_ATTRIBUTES ObjectAttributes);
__declspec(dllimport) NTSTATUS __stdcall NtSuspendThread(__in HANDLE ThreadHandle,__out_opt PULONG PreviousSuspendCount);
__declspec(dllimport) NTSTATUS __stdcall NtResumeThread(__in HANDLE ThreadHandle,__out_opt PULONG SuspendCount);
__declspec(dllimport) void     __stdcall RtlCaptureContext(__out  PCONTEXT ContextRecord);
__declspec(dllimport) NTSTATUS __stdcall NtGetContextThread(__in HANDLE ThreadHandle,__out PCONTEXT pContext);
__declspec(dllimport) NTSTATUS __stdcall NtSetContextThread(__in HANDLE ThreadHandle,__in PCONTEXT  pContext);
__declspec(dllimport) NTSTATUS __stdcall RtlRemoteCall(__in HANDLE Process,__in HANDLE Thread,__in PVOID CallSite,__in ULONG ArgumentCount,__in PULONG Arguments,__in BOOLEAN PassContext,__in BOOLEAN AlreadySuspended);
__declspec(dllimport) NTSTATUS __stdcall NtYieldExecution();
__declspec(dllimport) NTSTATUS __stdcall NtFlushInstructionCache(__in HANDLE Process,__in PVOID BaseAddress,__in ULONG NumberOfBytesToFlush);
__declspec(dllimport) NTSTATUS __stdcall NtRaiseException(__in PEXCEPTION_RECORD ExceptionRecord,__in PCONTEXT ThreadContext,__in BOOLEAN HandleException );
__declspec(dllimport) NTSTATUS __stdcall LdrFindEntryForAddress(__in const void* addr,PLDR_MODULE* mod);
__declspec(dllimport) NTSTATUS __stdcall NtQueryVirtualMemory(__in HANDLE ProcessHandle,__in PVOID BaseAddress,__in MEMORY_INFORMATION_CLASS MemoryInformationClass,__out PVOID Buffer,__in ULONG Length,__out_opt PULONG ResultLength);

__declspec(dllimport) NTSTATUS __stdcall NtReadRequestData(

  IN HANDLE               PortHandle,
  IN PPORT_MESSAGE         Request,
  IN ULONG                DataIndex,
  OUT PVOID               Buffer,
  IN ULONG                Length,
  OUT PULONG              ResultLength OPTIONAL );

__declspec(dllimport) NTSTATUS __stdcall NtWriteRequestData(

  IN HANDLE               PortHandle,
  IN PPORT_MESSAGE         Request,
  IN ULONG                DataIndex,
  IN PVOID                Buffer,
  IN ULONG                Length,
  OUT PULONG              ResultLength OPTIONAL );

}

__declspec(naked) ULONG_PTR __stdcall NtCurrentThreadId()
{
#ifdef _M_IX86
	__asm mov eax,fs:[0x18];
	__asm mov eax,dword ptr [eax+0x24];
	__asm ret;
#elif _IA64_
	ThreadId = (ULONG_PTR*)NtCurrentTeb()->ClientId.UniqueThread;
#endif	
}

__declspec(naked) ULONG_PTR __stdcall NtCurrentProcessId()
{
#ifdef _M_IX86
	__asm mov eax, fs:[0x18];
	__asm mov eax, dword ptr [eax+0x20];
	__asm ret;
#elif _IA64_
	ProcessId = (ULONG_PTR*)NtCurrentTeb()->ClientId.UniqueProcess;
#endif
}